package com.yshkj.payment.utils;

import java.util.Random;

/**
 * 随机字符串生成类
 * Created by 唐旭 on 2015/11/3.
 */
public abstract class RandomStringUtils {
    private RandomStringUtils() {

    }

    /**
     * 生成一个指定位数的随机数
     *
     * @param length 生成的字符串长度
     * @return 生成的随机字符串
     */
    public static String nextString(int length) {
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        return sb.toString();
    }
}
